
local unity = require "luaUnity"
local nl = require"luaNumeric"
require("lfs")

--==============================================================================================================--
--设置默认参数
local CSSModule=require"luaFDM2D"
local FDM2D = CSSModule.VecFDM2D;
--==============================================================================================================--


function create_inter()
	local inter = Geometry.NewInterpolate2()

	data = unity.file_to_num_table('D:/temp/天线罩电热/data.txt','\t')

	print_table(data[8])

	print(data[8][5+6] )

	for ii=8,#data-1 do 
		inter:insert( data[ii][1], data[ii][2], data[ii][ 5 ] );
	end
	return inter;
end

function FDM2D:create(  )
	self:update_parameters_from_ui();
	Geometry.clear_all()
	self:clear();
	self:set_init_alpha_beta(1,0)
	
	self:mesh():dmax(5)
	


	local rad = Geometry.load_step( 'D:/temp/天线罩电热/rad.stp' )

	r=300;
	w=10
	dx = 230;
	arc = Geometry.create_arc( {pts={{-r+dx,0,0},{0+dx,r,0},{r+dx,0,0} }});
	arc1 = Geometry.create_arc( {pts={{-r+dx,0,0},{0+dx,-r,0},{r+dx,0,0} }});
	outer = Geometry.join({arc,arc1})

	local cir = Geometry.create_circle({radius=r,pt={dx,0}});
	
	local rect = Geometry.create_rect({pt1={-w+dx,-w},pt2={w+dx,w}});
	
	Geometry.AddShape(outer)
	Geometry.AddShape(cir)
	Geometry.AddShape(rad)
	--Geometry.AddShape(rect)

	self:add_shape(outer);
	--self:add_shape(rect);
	self:add_shape(rad:copy());
	self:add_shape(cir);
	self:set_shapes();
	
	print( 'init material' )
	self:init_material();
	self:init_matrix();
	
	--self:set_f(1,0.01);
	self:set_matrix();
	--self:set_D_BCs(2,0);
	print( 'init material' )
	--self:set_D_BCs(0,0 );
	--self:set_D_BCs(1,1 );
	
	print( 'set D Matrix' )
	self:set_D_Matrix();
	print( 'solve' )
	self:solve();
	print( 'post' )
	self:post_calculate();
	
	--print(self.spF)
	--print(self.vecb)
--self:mesh():is_outline(false);

	Geometry.AddShape( self:mesh() );
end


--==============================================================================================================--
function FDM2D:calculate()
	self:create();
end
--==============================================================================================================--

return FDM2D; 
